<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 150px;
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Account Name：</label>
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="account_name" lay-verify="title" placeholder="Account Name" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
                <a href="{:url('sourceAdd')}" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe608;</i>Add</a>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>

<script>
    layui.use(['form', 'table'], function () {
        var tableIn =layui.table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            url: "{:url('balance/index')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'fund_name_cn', align: 'center', title: 'Fund Name Cn' },
                { field: 'fund_name_en', align: 'center', title: 'Fund Name En' },
                { field: 'account_number', align: 'center',  title: 'Account Number'},
                { field: 'account_name', align: 'center',  title: 'Account name'},
                { field: 'swift_code', align: 'center',  title: 'Swift Code' },
                { field: 'option', title: 'Option',
                    templet: function (d) {
                        var html = '<a class="layui-btn layui-btn-xs" href="{:url(\'sourceEdit\')}?id=' + d.id + '">Edit</a>';
                        // html += '<a class="layui-btn layui-btn-xs option-del layui-btn-danger" data-id="' + d.id + '">del</a>';
                        return html;
                    }, align: 'center'
                }
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        layui.form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //角色删除
        $(document).on('click', '.option-del', function () {
            var id = $(this).attr('data-id');
            layer.confirm('Are you sure you want to delete it?', {
                btn: ['confirm', 'cancel'] //按钮
            }, function () {
                //去删除
                JsPost("{:url('fundDel')}", { 'id': id }, function (res) {
                    if (res.code>0) {
                        layer.msg(res.msg , {time: 1500, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(res.msg , {time: 1500, icon: 2});
                    }
                });
            }, function () {
                layer.close(1);
            });
        });
    });
</script>